/*
 * Copyright (c) 2025.
 * All rights reserved.
 */

#include "string_utils.h"

BOOLEAN InitUnicodeString(
	_In_ PUNICODE_STRING pStr,
	_In_ USHORT sizeOfWchar,
	_In_ ULONG poolTag)
{
	pStr->Length = 0;
	pStr->MaximumLength = sizeOfWchar * sizeof(WCHAR);
	pStr->Buffer = ExAllocatePool2(POOL_FLAG_NON_PAGED, pStr->MaximumLength, poolTag);
	if (pStr->Buffer == NULL) {
		pStr->MaximumLength = 0;
		return FALSE;
	}

	RtlZeroMemory(pStr->Buffer, pStr->MaximumLength);
	return TRUE;
}
BOOLEAN IsNullOrEmpty(
	_In_ PCUNICODE_STRING pStr)
{
	if (pStr == NULL) {
		return TRUE;
	}
	if (pStr->Buffer == NULL || pStr->Length == 0) {
		return TRUE;
	}
	return FALSE;
}
VOID FreeUnicodeString(
	_In_ PUNICODE_STRING pStr)
{
	if (pStr == NULL || pStr->Buffer == NULL) {
		return;
	}
	ExFreePool(pStr->Buffer);
}